home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / u_man / cat1 / perlfaq1.Z / perlfaq1
Encoding:
Text File  |  1998-10-28  |  19.6 KB  |  463 lines

  1.  
  2.  
  3.  
  4.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       perlfaq1 - General Questions About Perl ($Revision: 1.15 $,
  10.       $Date: 1998/08/05 11:52:24 $)
  11.  
  12.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  13.       This section of the FAQ answers very general,    high-level
  14.       questions about Perl.
  15.  
  16.       WWWWhhhhaaaatttt iiiissss PPPPeeeerrrrllll????
  17.  
  18.       Perl is a high-level programming language with an eclectic
  19.       heritage written by Larry Wall and a cast of thousands.  It
  20.       derives from the ubiquitous C    programming language and to a
  21.       lesser extent    from sed, awk, the Unix    shell, and at least a
  22.       dozen    other tools and    languages.  Perl's process, file, and
  23.       text manipulation facilities make it particularly well-
  24.       suited for tasks involving quick prototyping,    system
  25.       utilities, software tools, system management tasks, database
  26.       access, graphical programming, networking, and world wide
  27.       web programming.  These strengths make it especially popular
  28.       with system administrators and CGI script authors, but
  29.       mathematicians, geneticists, journalists, and    even managers
  30.       also use Perl.  Maybe    you should, too.
  31.  
  32.       WWWWhhhhoooo ssssuuuuppppppppoooorrrrttttssss PPPPeeeerrrrllll????  WWWWhhhhoooo ddddeeeevvvveeeellllooooppppssss iiiitttt????    WWWWhhhhyyyy iiiissss iiiitttt ffffrrrreeeeeeee????
  33.  
  34.       The original culture of the pre-populist Internet and    the
  35.       deeply-held beliefs of Perl's    author,    Larry Wall, gave rise
  36.       to the free and open distribution policy of perl.  Perl is
  37.       supported by its users.  The core, the standard Perl
  38.       library, the optional    modules, and the documentation you're
  39.       reading now were all written by volunteers.  See the
  40.       personal note    at the end of the README file in the perl
  41.       source distribution for more details.     See the _p_e_r_l_h_i_s_t
  42.       manpage (new as of 5.005) for    Perl's milestone releases.
  43.  
  44.       In particular, the core development team (known as the Perl
  45.       Porters) are a rag-tag band of highly    altruistic individuals
  46.       committed to producing better    software for free than you
  47.       could    hope to    purchase for money.  You may snoop on pending
  48.       developments via news://genetics.upenn.edu/perl.porters-gw/
  49.       and http://www.frii.com/~gnat/perl/porters/summary.html.
  50.  
  51.       While    the GNU    project    includes Perl in its distributions,
  52.       there's no such thing    as "GNU    Perl".    Perl is    not produced
  53.       nor maintained by the    Free Software Foundation.  Perl's
  54.       licensing terms are also more    open than GNU software's tend
  55.       to be.
  56.  
  57.       You can get commercial support of Perl if you    wish, although
  58.       for most users the informal support will more    than suffice.
  59.       See the answer to "Where can I buy a commercial version of
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  71.  
  72.  
  73.  
  74.       perl?" for more information.
  75.  
  76.       WWWWhhhhiiiicccchhhh    vvvveeeerrrrssssiiiioooonnnn    ooooffff PPPPeeeerrrrllll    sssshhhhoooouuuulllldddd IIII uuuusssseeee????
  77.  
  78.       You should definitely    use version 5.    Version    4 is old,
  79.       limited, and no longer maintained; its last patch (4.036)
  80.       was in 1992.    The most recent    production release is
  81.       5.005_01.  Further references    to the Perl language in    this
  82.       document refer to this production release unless otherwise
  83.       specified.  There may    be one or more official    bug fixes for
  84.       5.005_01 by the time you read    this, and also perhaps some
  85.       experimental versions    on the way to the next release.
  86.  
  87.       WWWWhhhhaaaatttt aaaarrrreeee ppppeeeerrrrllll4444 aaaannnndddd ppppeeeerrrrllll5555????
  88.  
  89.       Perl4    and perl5 are informal names for different versions of
  90.       the Perl programming language.  It's easier to say "perl5"
  91.       than it is to    say "the _5(.004) release of Perl", but some
  92.       people have interpreted this to mean there's a language
  93.       called "perl5", which    isn't the case.     Perl5 is merely the
  94.       popular name for the fifth major release (October 1994),
  95.       while    perl4 was the fourth major release (March 1991).
  96.       There    was also a perl1 (in January 1988), a perl2 (June
  97.       1988), and a perl3 (October 1989).
  98.  
  99.       The 5.0 release is, essentially, a complete rewrite of the
  100.       perl source code from    the ground up.    It has been
  101.       modularized, object-oriented,    tweaked, trimmed, and
  102.       optimized until it almost doesn't look like the old code.
  103.       However, the interface is mostly the same, and compatibility
  104.       with previous    releases is very high.
  105.  
  106.       To avoid the "what language is perl5?" confusion, some
  107.       people prefer    to simply use "perl" to    refer to the latest
  108.       version of perl and avoid using "perl5" altogether.  It's
  109.       not really that big a    deal, though.
  110.  
  111.       See the _p_e_r_l_h_i_s_t manpage for a history of Perl revisions.
  112.  
  113.       HHHHoooowwww ssssttttaaaabbbblllleeee iiiissss    PPPPeeeerrrrllll????
  114.  
  115.       Production releases, which incorporate bug fixes and new
  116.       functionality, are widely tested before release.  Since the
  117.       5.000    release, we have averaged only about one production
  118.       release per year.
  119.  
  120.       Larry    and the    Perl development team occasionally make
  121.       changes to the internal core of the language,    but all
  122.       possible efforts are made toward backward compatibility.
  123.       While    not quite all perl4 scripts run    flawlessly under
  124.       perl5, an update to perl should nearly never invalidate a
  125.       program written for an earlier version of perl (barring
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  137.  
  138.  
  139.  
  140.       accidental bug fixes and the rare new    keyword).
  141.  
  142.       IIIIssss PPPPeeeerrrrllll ddddiiiiffffffffiiiiccccuuuulllltttt ttttoooo lllleeeeaaaarrrrnnnn????
  143.  
  144.       No, Perl is easy to start learning --    and easy to keep
  145.       learning.  It    looks like most    programming languages you're
  146.       likely to have experience with, so if    you've ever written an
  147.       C program, an    awk script, a shell script, or even BASIC
  148.       program, you're already part way there.
  149.  
  150.       Most tasks only require a small subset of the    Perl language.
  151.       One of the guiding mottos for    Perl development is "there's
  152.       more than one    way to do it" (TMTOWTDI, sometimes pronounced
  153.       "tim toady").     Perl's    learning curve is therefore shallow
  154.       (easy    to learn) and long (there's a whole lot    you can    do if
  155.       you really want).
  156.  
  157.       Finally, Perl    is (frequently)    an interpreted language.  This
  158.       means    that you can write your    programs and test them without
  159.       an intermediate compilation step, allowing you to experiment
  160.       and test/debug quickly and easily.  This ease    of
  161.       experimentation flattens the learning    curve even more.
  162.  
  163.       Things that make Perl    easier to learn: Unix experience,
  164.       almost any kind of programming experience, an    understanding
  165.       of regular expressions, and the ability to understand    other
  166.       people's code.  If there's something you need    to do, then
  167.       it's probably    already    been done, and a working example is
  168.       usually available for    free.  Don't forget the    new perl
  169.       modules, either.  They're discussed in Part 3    of this    FAQ,
  170.       along    with the CPAN, which is    discussed in Part 2.
  171.  
  172.       HHHHoooowwww ddddooooeeeessss PPPPeeeerrrrllll    ccccoooommmmppppaaaarrrreeee    wwwwiiiitttthhhh ooootttthhhheeeerrrr llllaaaannnngggguuuuaaaaggggeeeessss lllliiiikkkkeeee JJJJaaaavvvvaaaa,,,,
  173.       PPPPyyyytttthhhhoooonnnn,,,, RRRREEEEXXXXXXXX,,,,    SSSScccchhhheeeemmmmeeee,,,,    oooorrrr TTTTccccllll????
  174.  
  175.       Favorably in some areas, unfavorably in others.  Precisely
  176.       which    areas are good and bad is often    a personal choice, so
  177.       asking this question on Usenet runs a    strong risk of
  178.       starting an unproductive Holy    War.
  179.  
  180.       Probably the best thing to do    is try to write    equivalent
  181.       code to do a set of tasks.  These languages have their own
  182.       newsgroups in    which you can learn about (but hopefully not
  183.       argue    about) them.
  184.  
  185.       CCCCaaaannnn IIII    ddddoooo [[[[ttttaaaasssskkkk]]]] iiiinnnn PPPPeeeerrrrllll????
  186.  
  187.       Perl is flexible and extensible enough for you to use    on
  188.       almost any task, from    one-line file-processing tasks to
  189.       complex systems.  For    many people, Perl serves as a great
  190.       replacement for shell    scripting.  For    others,    it serves as a
  191.       convenient, high-level replacement for most of what they'd
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  203.  
  204.  
  205.  
  206.       program in low-level languages like C    or C++.     It's
  207.       ultimately up    to you (and possibly your management ...)
  208.       which    tasks you'll use Perl for and which you    won't.
  209.  
  210.       If you have a    library    that provides an API, you can make any
  211.       component of it available as just another Perl function or
  212.       variable using a Perl    extension written in C or C++ and
  213.       dynamically linked into your main perl interpreter.  You can
  214.       also go the other direction, and write your main program in
  215.       C or C++, and    then link in some Perl code on the fly,    to
  216.       create a powerful application.
  217.  
  218.       That said, there will    always be small, focused, special-
  219.       purpose languages dedicated to a specific problem domain
  220.       that are simply more convenient for certain kinds of
  221.       problems.  Perl tries    to be all things to all    people,    but
  222.       nothing special to anyone.  Examples of specialized
  223.       languages that come to mind include prolog and matlab.
  224.  
  225.       WWWWhhhheeeennnn sssshhhhoooouuuullllddddnnnn''''tttt IIII pppprrrrooooggggrrrraaaammmm iiiinnnn PPPPeeeerrrrllll????
  226.  
  227.       When your manager forbids it -- but do consider replacing
  228.       them :-).
  229.  
  230.       Actually, one    good reason is when you    already    have an
  231.       existing application written in another language that's all
  232.       done (and done well),    or you have an application language
  233.       specifically designed    for a certain task (e.g. prolog,
  234.       make).
  235.  
  236.       For various reasons, Perl is probably    not well-suited    for
  237.       real-time embedded systems, low-level    operating systems
  238.       development work like    device drivers or context-switching
  239.       code,    complex    multithreaded shared-memory applications, or
  240.       extremely large applications.     You'll    notice that perl is
  241.       not itself written in    Perl.
  242.  
  243.       The new native-code compiler for Perl    may reduce the
  244.       limitations given in the previous statement to some degree,
  245.       but understand that Perl remains fundamentally a dynamically
  246.       typed    language, and not a statically typed one.  You
  247.       certainly won't be chastized if you don't trust nuclear-
  248.       plant    or brain-surgery monitoring code to it.     And Larry
  249.       will sleep easier, too -- Wall Street    programs not
  250.       withstanding.    :-)
  251.  
  252.       WWWWhhhhaaaatttt''''ssss tttthhhheeee ddddiiiiffffffffeeeerrrreeeennnncccceeee    bbbbeeeettttwwwweeeeeeeennnn    """"ppppeeeerrrrllll"""" aaaannnndddd """"PPPPeeeerrrrllll""""????
  253.  
  254.       One bit.  Oh,    you weren't talking ASCII? :-) Larry now uses
  255.       "Perl" to signify the    language proper    and "perl" the
  256.       implementation of it,    i.e. the current interpreter.  Hence
  257.       Tom's    quip that "Nothing but perl can    parse Perl."  You may
  258.  
  259.  
  260.  
  261.      Page 4                        (printed 10/23/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  269.  
  270.  
  271.  
  272.       or may not choose to follow this usage.  For example,
  273.       parallelism means "awk and perl" and "Python and Perl" look
  274.       ok, while "awk and Perl" and "Python and perl" do not.
  275.  
  276.       IIIIssss iiiitttt    aaaa PPPPeeeerrrrllll pppprrrrooooggggrrrraaaammmm oooorrrr aaaa PPPPeeeerrrrllll ssssccccrrrriiiipppptttt????
  277.  
  278.       It doesn't matter.
  279.  
  280.       In "standard terminology" a _p_r_o_g_r_a_m has been compiled    to
  281.       physical machine code    once, and can then be be run multiple
  282.       times, whereas a _s_c_r_i_p_t must be translated by    a program each
  283.       time it's used.  Perl    programs, however, are usually neither
  284.       strictly compiled nor    strictly interpreted.  They can    be
  285.       compiled to a    byte code form (something of a Perl virtual
  286.       machine) or to completely different languages, like C    or
  287.       assembly language.  You can't    tell just by looking whether
  288.       the source is    destined for a pure interpreter, a parse-tree
  289.       interpreter, a byte code interpreter,    or a native-code
  290.       compiler, so it's hard to give a definitive answer here.
  291.  
  292.       WWWWhhhhaaaatttt iiiissss aaaa JJJJAAAAPPPPHHHH????
  293.  
  294.       These    are the    "just another perl hacker" signatures that
  295.       some people sign their postings with.     About 100 of the of
  296.       the earlier ones are available from
  297.       http://www.perl.com/CPAN/misc/japh .
  298.  
  299.       WWWWhhhheeeerrrreeee    ccccaaaannnn IIII ggggeeeetttt aaaa lllliiiisssstttt ooooffff LLLLaaaarrrrrrrryyyy WWWWaaaallllllll wwwwiiiittttttttiiiicccciiiissssmmmmssss????
  300.  
  301.       Over a hundred quips by Larry, from postings of his or
  302.       source code, can be found at
  303.       http://www.perl.com/CPAN/misc/lwall-quotes .
  304.  
  305.       HHHHoooowwww ccccaaaannnn IIII ccccoooonnnnvvvviiiinnnncccceeee mmmmyyyy    ssssyyyyssssaaaaddddmmmmiiiinnnn////ssssuuuuppppeeeerrrrvvvviiiissssoooorrrr////eeeemmmmppppllllooooyyyyeeeeeeeessss ttttoooo uuuusssseeee
  306.       vvvveeeerrrrssssiiiioooonnnn ((((5555////5555....000000005555////PPPPeeeerrrrllll    iiiinnnnsssstttteeeeaaaadddd    ooooffff ssssoooommmmeeee    ooootttthhhheeeerrrr llllaaaannnngggguuuuaaaaggggeeee))))????
  307.  
  308.       If your manager or employees are wary    of unsupported
  309.       software, or software    which doesn't officially ship with
  310.       your Operating System, you might try to appeal to their
  311.       self-interest.  If programmers can be    more productive    using
  312.       and utilizing    Perl constructs, functionality,    simplicity,
  313.       and power, then the typical manager/supervisor/employee may
  314.       be persuaded.     Regarding using Perl in general, it's also
  315.       sometimes helpful to point out that delivery times may be
  316.       reduced using    Perl, as compared to other languages.
  317.  
  318.       If you have a    project    which has a bottleneck,    especially in
  319.       terms    of translation or testing, Perl    almost certainly will
  320.       provide a viable, and    quick solution.     In conjunction    with
  321.       any persuasion effort, you should not    fail to    point out that
  322.       Perl is used,    quite extensively, and with extremely reliable
  323.       and valuable results,    at many    large computer software    and/or
  324.  
  325.  
  326.  
  327.      Page 5                        (printed 10/23/98)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  335.  
  336.  
  337.  
  338.       hardware companies throughout    the world.  In fact, many Unix
  339.       vendors now ship Perl    by default, and    support    is usually
  340.       just a news-posting away, if you can't find the answer in
  341.       the _c_o_m_p_r_e_h_e_n_s_i_v_e documentation, including this FAQ.
  342.  
  343.       If you face reluctance to upgrading from an older version of
  344.       perl,    then point out that version 4 is utterly unmaintained
  345.       and unsupported by the Perl Development Team.     Another big
  346.       sell for Perl5 is the    large number of    modules    and extensions
  347.       which    greatly    reduce development time    for any    given task.
  348.       Also mention that the    difference between version 4 and
  349.       version 5 of Perl is like the    difference between awk and
  350.       C++.    (Well, ok, maybe not quite that    distinct, but you get
  351.       the idea.)  If you want support and a    reasonable guarantee
  352.       that what you're developing will continue to work in the
  353.       future, then you have    to run the supported version.  That
  354.       probably means running the 5.005 release, although 5.004
  355.       isn't    that bad (it's just one    year and one release behind).
  356.       Several important bugs were fixed from the 5.000 through
  357.       5.003    versions, though, so try upgrading past    them if
  358.       possible.
  359.  
  360.       Of particular    note is    the massive bughunt for    buffer
  361.       overflow problems that went into the 5.004 release.  All
  362.       releases prior to that, including perl4, are considered
  363.       insecure and should be upgraded as soon as possible.
  364.  
  365.      AAAAUUUUTTTTHHHHOOOORRRR AAAANNNNDDDD    CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT
  366.       Copyright (c)    1997, 1998 Tom Christiansen and    Nathan
  367.       Torkington.  All rights reserved.
  368.  
  369.       When included    as an integrated part of the Standard
  370.       Distribution of Perl or of its documentation (printed    or
  371.       otherwise), this works is covered under Perl's Artistic
  372.       Licence.  For    separate distributions of all or part of this
  373.       FAQ outside of that, see the _p_e_r_l_f_a_q manpage.
  374.  
  375.       Irrespective of its distribution, all    code examples here are
  376.       public domain.  You are permitted and    encouraged to use this
  377.       code and any derivatives thereof in your own programs    for
  378.       fun or for profit as you see fit.  A simple comment in the
  379.       code giving credit to    the FAQ    would be courteous but is not
  380.       required.
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                        (printed 10/23/98)
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))      5555////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))       PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.      Page 7                        (printed 10/23/98)
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.